<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加服务</title>
    <style>
        .wu-pos-a {
            box-sizing: border-box;
            padding-top: 39px;
            width: 20%;
            left: auto;
            right: 0;
        }
        .wu-inline>.form-group{
             margin-right:0;
             margin-left:0;
        }
    </style>
</head>
<body>

<div class="pos-r">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        点位管理
        <span class="c-gray en">&gt;</span>
        点位管理
        <span class="c-gray en">&gt;</span>
        添加点位
    </nav>
    <!--<div class="pos-a wu-pos-a" >-->
        <!--<div class="wu-tree">点位可服务项目</div>-->
        <!--<div class="wu-treeBox">-->
            <!--<ul id="addStoreServiceTree" class="ztree"></ul>-->
        <!--</div>-->
    <!--</div>-->

    <div>
        <div class="page-container">
            <form action="" method="post" class="form form-horizontal" id="store-form-member-add">
                <input style="display: none;" id="addStoreServiceTreeArray" name="array"/>
                <div class="form-unit">基本信息</div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>点位名称：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-shopName" name="shopName">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>设备ID：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-boxUid" name="boxUid">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>设备编号：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-boxNo" name="boxNo">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>点位地址：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-shopAddr" name="shopAddr">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>洗车价格一：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-price" name="price">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格一模式名称：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceMode" name="priceMode">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格一模式介绍：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceRemark" name="priceRemark">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>洗车价格二：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceTwo" name="priceTwo">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格二模式名称：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceTwoMode" name="priceTwoMode">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格二模式介绍：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceTwoRemark" name="priceTwoRemark">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>洗车价格三：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceThree" name="priceThree">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格三模式名称：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceThreeMode" name="priceThreeMode">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>价格三模式介绍：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="必填项" id="store-add-priceThreeRemark" name="priceThreeRemark">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>标准编码：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="向山西中石化推送时填写，否则直接不填" id="store-add-oucode" name="oucode">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>商户编码：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="向山西中石化推送时填写，否则直接不填" id="store-add-mchcode" name="mchcode">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>充值一：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pOne" name="pOne">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>赠送一：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pGiveOne" name="pGiveOne">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>充值二：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pTwo" name="pTwo">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>赠送二：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pGiveTwo" name="pGiveTwo">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>充值三：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pThree" name="pThree">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>赠送三：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pGiveThree" name="pGiveThree">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>充值四：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pFour" name="pFour">
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>赠送四：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <input type="text" class="form-control" value="" placeholder="从上到下，依次填写" id="store-add-pGiveFour" name="pGiveFour">
                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>所属企业：</label>
                    <div class="formControls col-xs-4 col-sm-4">
                        <select class="form-control" name="subMchName" id="store-add-subMchName">
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-xs-4 col-sm-3"><span class="c-red"></span>获取经纬度：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <div class="form-inline wu-inline">
                            <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".modal-map">地图获取经纬度</button>
                            <div class="form-group">
                                <!--<input type="text" class="form-control" placeholder="经度">-->
                                <input type="text" class="form-control" value="" placeholder="经度" id="store-add-longitude" name="longitude">
                            </div>
                            <div class="form-group">
                                <!--<input type="text" class="form-control"  placeholder="纬度">-->
                                <input type="text" class="form-control" value="" placeholder="纬度" id="store-add-latitude" name="latitude">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input onclick="merchantStoreManageAddFun.submitAction();return false;" class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;"/>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<!--地图模态框-->
<div class="modal fade modal-map" tabindex="-1" role="dialog" id="mapModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <input type="text" id="word">
            <button id="searchWord">搜索</button>
            <div id="wuTestMap" style="min-height: 700px;width: 100%"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //点位管理，添加服务
    var merchantStoreManageAddFun;

    merchantStoreManageAddFun = {
        init: function () {
            let _this = this;

            //加载门店名称
            $.ajax({
                type: "GET",
                url: "biz/getWxBizShopMchDtoList",
                dataType: "json",
                success: function (data) {
                    for(var i = 0;i<data.data.length;i++){
                        if (i == 0){
                            $("#store-add-subMchName").append("<option value='"+data.data[i].id+"' selected='selected'>"+data.data[i].text+"</option>");
                        }else {
                            $("#store-add-subMchName").append("<option value='"+data.data[i].id+"'>"+data.data[i].text+"</option>");
                        }
                    }
                },
                error: function () {
                    alert("error");
                }
            });

            $("#store-add-addDesc").Huitextarealength({
                minlength: 10,
                maxlength: 300
            });
//            _this.serviceType();
            _this.bootstrapvalidatorForm();
            /*加载地图*/
            var map = new BMap.Map("wuTestMap");
            map.centerAndZoom("太仓",15);
            map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
            //单击获取点击的经纬度
            map.addEventListener("click",function(e){
                $('#mapModalLabel').modal('hide');
                //alert(e.point.lng + "," + e.point.lat);
                $("#store-add-longitude").val(e.point.lng);
                $("#store-add-latitude").val(e.point.lat);

            });
            var local = new BMap.LocalSearch(map, {
                renderOptions:{map: map}
            });
            $('#searchWord').on('click',function(){
                var val = $('#word').val();
                local.search(val);
            })
            /*时间控件*/
            /***********设置日期控件*********/
//            $("#store-add-startTime").on('focus',function () {
//                WdatePicker({
//                    el : this,
//                    readOnly:true,
//                    dateFmt: 'HH:mm',
//                    startDate : '',
//                    isShowClear : false
//                })
//            });
//            $("#store-add-endTime").on('focus',function () {
//                WdatePicker({
//                    el : this,
//                    readOnly:true,
//                    dateFmt: 'HH:mm',
//                    isShowClear : false
//                })
//            });

//            //给点位设置默认值
//            $.ajax({
//                type: "GET",
//                url: "biz/getBizTenantByOne",
//                dataType: "json",
//                success: function (data) {
//                    if(data.state){
//                        var json = data.data;
//                        $("#store-add-shopName").val(json.bizName);
//                        $("#store-add-shopPhone1").val(json.phone);
//                        $("#store-add-shopAddr").val(json.address);
//                        $("#store-add-shopDesc").val(json.bizDesc);
//                    }else {
//                        alert("error");
//                    }
//                },
//                error: function () {
//                    alert("error");
//                }
//            });

        },
        //表单提交
        submitAction: function () {
            //bootstrap验证
            var bootstrapValidator = $("#store-form-member-add").data('bootstrapValidator');
            bootstrapValidator.validate();
            if(bootstrapValidator.isValid())
                $("#store-form-member-add").submit();
            else return;

            //提交
            $.ajax({
                type: "GET",
                url: "biz/insertShop",
                data: $("#store-form-member-add").serialize(),
                dataType: "json",
                success: function (data) {
                    if (data.state) {
                        //关闭新增窗口
                        removeIframe();
                        merchantStoreManageFun.searchAction();
                    } else {
                        $("#store-add-usernameSpan").text(data.message);
                    }
                },
                error: function () {
                    alert("error");
                }
            });
        },
        //bootstrap验证
        bootstrapvalidatorForm: function () {
            $('#store-form-member-add').bootstrapValidator({
                message: 'This value is not valid',
                excluded : [':disabled'],
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    shopName: {
                        validators: {
                            notEmpty: {
                                message: '点位名称不能为空'
                            },
                            stringLength: {
                                min: 2,
                                max: 100,
                                message: '点位名称长度必须在2到100位之间'
                            }
                        }
                    },
                    unid: {
                        validators: {
                            notEmpty: {
                                message: '设备编号不能为空'
                            },
                            stringLength: {
                                min: 2,
                                max: 20,
                                message: '设备编号长度必须在2到20位之间'
                            }
                        }
                    },
                    shopAddr: {
                        validators: {
                            notEmpty: {
                                message: '点位地址不能为空'
                            },
                            stringLength: {
                                min: 2,
                                max: 200,
                                message: '点位地址长度必须在2到200位之间'
                            }
                        }
                    },
                    longitude: {
                        validators: {
                            notEmpty: {
                                message: '经度不能为空'
                            },
                            regexp: {
                                regexp: /^-?((0|[1-9]\d?|1[1-7]\d)(\.\d{1,6})?|180(\.0{1,6})?)?$/,
                                message: '经度格式不正确'
                            }
                        }
                    },
                    latitude: {
                        validators: {
                            notEmpty: {
                                message: '纬度不能为空'
                            },
                            regexp: {
                                regexp: /^-?((0|[1-8]\d?)(\.\d{1,6})?|90(\.0{1,6})?)?$/,
                                message: '纬度格式不正确'
                            }
                        }
                    }
                }
            });
        }
    };

    merchantStoreManageAddFun.init();
</script>
</body>
</html>